﻿// <copyright file="ResourceAttribute.cs" company="Lu Studio">
// Copyright (c) Lu Studio. All rights reserved.
// </copyright>
// <author>lu qi</author>
// <createTime>2021-06-19</createTime>

namespace ElfKit.Common
{
    using System;
    using System.Globalization;

    /// <summary>
    /// 资源自定义属性.
    /// </summary>
    public sealed class ResourceAttribute : Attribute
    {
        /// <summary>
        ///  构造函数.
        /// </summary>
        /// <param name="resourceType">资源类型.</param>
        /// <param name="resourceName">资源名称.</param>
        /// <param name="cultureName">文化名称.</param>
        public ResourceAttribute(Type resourceType, string resourceName,string cultureName)
            :this(resourceType, resourceName)
        {
            Guard.NotNullOrWhiteSpace(cultureName, nameof(cultureName));
            this.Culture = new CultureInfo(cultureName);
        }

        /// <summary>
        ///  构造函数.
        /// </summary>
        /// <param name="resourceType">资源类型.</param>
        /// <param name="resourceName">资源名称.</param>
        public ResourceAttribute(Type resourceType, string resourceName)
        {
            Guard.NotNull(resourceType, nameof(resourceType));
            Guard.NotNullOrWhiteSpace(resourceName, nameof(resourceName));

            this.ResourceType = resourceType;
            this.ResourceName = resourceName;
        }

        /// <summary>
        /// 获得资源类型.
        /// </summary>
        public Type ResourceType { get; }

        /// <summary>
        /// 获得资源名称.
        /// </summary>
        public string ResourceName { get; }

        /// <summary>
        /// 获得<see cref="CultureInfo"/>实例.
        /// </summary>
        public CultureInfo Culture { get; }
    }
}